package com.zk.shop.servlet.reply;

import com.zk.shop.dao.ReplyDao;
import com.zk.shop.entity.Msg;
import com.zk.shop.entity.Reply;
import com.zk.shop.service.Impl.MsgServiceImpl;
import com.zk.shop.service.Impl.ReplyServiceImpl;
import com.zk.shop.service.MsgService;
import com.zk.shop.service.ReplyService;
import com.zk.shop.util.JSONServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@WebServlet("/SelectReplybyMsgId")
public class SelectReplybyMsgId extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ReplyService replyService = new ReplyServiceImpl();
       int msgid = Integer.parseInt(request.getParameter("msgId"));
    //   int msgid = 6;
        List<Reply> replyList=replyService.ReplyGetMsgId(msgid);

        if (replyList.size()>0){
            JSONServlet.getJson(request,response,replyList);
            System.out.println("查询当前留言ID下所有回复"+replyList.size());

        }
        else {
            System.out.println("查询当前reply下所有回复失败");
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
